/**
  ******************************************************************************
  * @file    app_DSTIN.h
  * @author  Feirui_Joe
  * @version V0.1
  * @date    07/26/2010
  * @brief   Outputs Driver
  ******************************************************************************
  * @copy
  *
  * <h2><center>&copy; COPYRIGHT 2010 Feirui</center></h2>
  */ 



/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef  __APP_DSTIN_H__
#define  __APP_DSTIN_H__


#ifdef __cplusplus
 extern "C" {
#endif


/**
  * @brief  INCLUDE FILES.
  */


/**
  * @brief GLOBALS RAM definition
  */
#ifdef   APP_GLOBALS_DSTIN
#define  APP_EXT_DSTIN
#else
#define  APP_EXT_DSTIN  extern
#endif



/* DstInputs OS_Flags config bits */
#define OSDSTINFlags_DstIn1Timing                   ((OS_FLAGS)DEF_BIT_00)
#define OSDSTINFlags_DstIn1Request                  ((OS_FLAGS)DEF_BIT_01)
#define OSDSTINFlags_DstIn2Timing                   ((OS_FLAGS)DEF_BIT_02)
#define OSDSTINFlags_DstIn2Request                  ((OS_FLAGS)DEF_BIT_03)
#define OSDSTINFlags_DstIn3Timing                   ((OS_FLAGS)DEF_BIT_04)
#define OSDSTINFlags_DstIn3Request                  ((OS_FLAGS)DEF_BIT_05)
#define OSDSTINFlags_DstIn4Timing                   ((OS_FLAGS)DEF_BIT_06)
#define OSDSTINFlags_DstIn4Request                  ((OS_FLAGS)DEF_BIT_07)
#define OSDSTINFlags_DstIn5Timing                   ((OS_FLAGS)DEF_BIT_08)
#define OSDSTINFlags_DstIn5Request                  ((OS_FLAGS)DEF_BIT_09)
#define OSDSTINFlags_DstIn6Timing                   ((OS_FLAGS)DEF_BIT_10)
#define OSDSTINFlags_DstIn6Request                  ((OS_FLAGS)DEF_BIT_11)
#define OSDSTINFlags_DstIn7Timing                   ((OS_FLAGS)DEF_BIT_12)
#define OSDSTINFlags_DstIn7Request                  ((OS_FLAGS)DEF_BIT_13)
#define OSDSTINFlags_DstIn8Timing                   ((OS_FLAGS)DEF_BIT_14)
#define OSDSTINFlags_DstIn8Request                  ((OS_FLAGS)DEF_BIT_15)
#define OSDSTINFlags_EMSTOPTiming                   ((OS_FLAGS)DEF_BIT_16)
#define OSDSTINFlags_EMSTOPRequest                  ((OS_FLAGS)DEF_BIT_17)
#define OSDSTINFlags_Reserved18                     ((OS_FLAGS)DEF_BIT_18)
#define OSDSTINFlags_Reserved19                     ((OS_FLAGS)DEF_BIT_19)
#define OSDSTINFlags_Reserved20                     ((OS_FLAGS)DEF_BIT_20)
#define OSDSTINFlags_Reserved21                     ((OS_FLAGS)DEF_BIT_21)
#define OSDSTINFlags_Reserved22                     ((OS_FLAGS)DEF_BIT_22)
#define OSDSTINFlags_Reserved23                     ((OS_FLAGS)DEF_BIT_23)
#define OSDSTINFlags_Reserved24                     ((OS_FLAGS)DEF_BIT_24)
#define OSDSTINFlags_Reserved25                     ((OS_FLAGS)DEF_BIT_25)
#define OSDSTINFlags_Reserved26                     ((OS_FLAGS)DEF_BIT_26)
#define OSDSTINFlags_Reserved27                     ((OS_FLAGS)DEF_BIT_27)
#define OSDSTINFlags_SpeedSignal                    ((OS_FLAGS)DEF_BIT_28)
#define OSDSTINFlags_SpeedTiming                    ((OS_FLAGS)DEF_BIT_29)
#define OSDSTINFlags_SpeedRequest                   ((OS_FLAGS)DEF_BIT_30)
#define OSDSTINFlags_Reserved31                     ((OS_FLAGS)DEF_BIT_31)

#define OSDSTINFlags_DSTINTIMING                    (OSDSTINFlags_DstIn1Timing | \
                                                     OSDSTINFlags_DstIn2Timing | \
                                                     OSDSTINFlags_DstIn3Timing | \
                                                     OSDSTINFlags_DstIn4Timing | \
                                                     OSDSTINFlags_DstIn5Timing | \
                                                     OSDSTINFlags_DstIn6Timing | \
                                                     OSDSTINFlags_DstIn7Timing | \
                                                     OSDSTINFlags_DstIn8Timing | \
                                                     OSDSTINFlags_EMSTOPTiming)

#define OSDSTINFlags_DSTINREQUEST                   (OSDSTINFlags_DstIn1Request | \
                                                     OSDSTINFlags_DstIn2Request | \
                                                     OSDSTINFlags_DstIn3Request | \
                                                     OSDSTINFlags_DstIn4Request | \
                                                     OSDSTINFlags_DstIn5Request | \
                                                     OSDSTINFlags_DstIn6Request | \
                                                     OSDSTINFlags_DstIn7Request | \
                                                     OSDSTINFlags_DstIn8Request | \
                                                     OSDSTINFlags_EMSTOPRequest)
                                                     
#define OSDSTINFlags_DSTINALL                       (OSDSTINFlags_DSTINTIMING|OSDSTINFlags_DSTINREQUEST)
#define OSDSTINFlags_SPEEDALL                       (OSDSTINFlags_SpeedSignal|OSDSTINFlags_SpeedTiming|OSDSTINFlags_SpeedRequest)
#define OSDSTINFlags_ALL                            (OSDSTINFlags_DSTINALL|OSDSTINFlags_SPEEDALL)
#define OSDSTINFlags_DefaultValue                   ((OS_FLAGS)0x00000000)


/**************************************************/

/* Bit order is same with "DstInputsOrd" */
APP_EXT_DSTIN uint16_t DigitalInputsRawCloseSta;      /* 0:Open; 1:Close */

APP_EXT_DSTIN uint16_t DigitalInput1ScanTiCount;
APP_EXT_DSTIN uint16_t DigitalInput2ScanTiCount;
APP_EXT_DSTIN uint16_t DigitalInput3ScanTiCount;
APP_EXT_DSTIN uint16_t DigitalInput4ScanTiCount;
APP_EXT_DSTIN uint16_t DigitalInput5ScanTiCount;
APP_EXT_DSTIN uint16_t DigitalInput6ScanTiCount;
APP_EXT_DSTIN uint16_t DigitalInput7ScanTiCount;
APP_EXT_DSTIN uint16_t DigitalInput8ScanTiCount;
APP_EXT_DSTIN uint16_t DigitalEMSTOPScanTiCount;


#define DstInputTimingFreq            10      /* 10HZ */










APP_EXT_DSTIN void PORGlobalRAMReset_DSTIN(void);

APP_EXT_DSTIN void DstInputsAction_LampTest            (uint8_t ActionSta);
APP_EXT_DSTIN void DstInputsAction_SimulateStopKey     (uint8_t ActionSta);
APP_EXT_DSTIN void DstInputsAction_SimulateManualKey   (uint8_t ActionSta);
APP_EXT_DSTIN void DstInputsAction_SimulateManualTest  (uint8_t ActionSta);
APP_EXT_DSTIN void DstInputsAction_SimulateAutokey     (uint8_t ActionSta);
APP_EXT_DSTIN void DstInputsAction_SimulateStartKey    (uint8_t ActionSta);
APP_EXT_DSTIN void DstInputsAction_SimulateGensLoadKey (uint8_t ActionSta);
APP_EXT_DSTIN void DstInputsAction_SimulateMainsLoadKey(uint8_t ActionSta);
APP_EXT_DSTIN void DstInputsAction_AuxManualStart      (uint8_t ActionSta);
APP_EXT_DSTIN void DstInputsAction_AutoModeLock        (uint8_t ActionSta);
APP_EXT_DSTIN void DstInputsAction_AutoModeInvaild     (uint8_t ActionSta);
APP_EXT_DSTIN void DstInputsAction_IdleControlMode     (uint8_t ActionSta);

#ifdef __cplusplus
}
#endif


#endif   /*  __APP_DSTIN_H__  */

/******************* (C) COPYRIGHT 2010 Feirui *****END OF FILE****/